/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author william
 */
public class  DataConvert {
    
    public static Date convertData(String date) {
        Date data = null;
        try {
            data = new SimpleDateFormat("dd/MM/yyyy").parse(date);
        } catch (ParseException ex) {
            //Msg.erro(null, "Erro ao converter data!!!\n\n" + ex.getMessage());
        }
        return data;
    }

    public static Date convertDataTime(String date) {
        Date data = null;
        try {
            data = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse(date);
        } catch (ParseException ex) {
          ex.printStackTrace();  //Msg.erro(null, "Erro ao converter data!!!\n\n" + ex.getMessage());
        }
        return data;
    }

    public static String convertDateTime(Date date) {
        return new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(date);
    }

    public static String convertData(Date date) {
        return new SimpleDateFormat("dd/MM/yyyy").format(date);
    }

    public static String convertData(Date date, String format) {
        return new SimpleDateFormat(format).format(date);
    }
    
    public static java.sql.Date convert(java.util.Date var){
        int day = var.getDate();
        int mom =var.getMonth();
        int year= var.getYear();
        return new java.sql.Date(year,mom,day);
    }
}
    